import { defineStore } from "pinia";
import { store } from "@/store";
import { useStorage } from "@vueuse/core";
import _ from 'lodash-es'



export const useTableFilterStore = defineStore("tableFilter", () => {
	// state
	
	// org START 党支部成员管理 字段表
	let org_DefalutList = ref([
	  { title: "姓名",prop:"name",align:"center",width:"" },
	  { title: "职位名称",prop:"position",align:"center",width:"" },
	  { title: "党支部",prop:"dzb.name",align:"center",width:"" },
	  { title: "照片", prop:"image",align:"center",width:"" },
	  { title: "民族", prop:"nation",align:"center",width:""},
	  { title: "入党时间",prop:"join_time",align:"center",width:""},
	  { title: "转正时间",prop:"zz_time",align:"center",width:"" },
	  { title: "进入支部时间",prop:"entry_time",align:"center",width:""}, 
	  { title: "排序",prop:"sort",align:"center",width:""}, 
	])
	let  org_DefalutSelect =ref(["姓名","职位名称","党支部","照片","民族","排序"]);
	const org_columns = ref(org_DefalutList.value)
	const org_checklist=ref(org_DefalutSelect.value);
	const org_columnsTemp=ref(org_DefalutList.value);
	const org_checklistTemp=ref(org_DefalutSelect.value);
	// org End 字段表
	
	
	// user START 字段表
	let user_DefalutList = ref([
	  { title: "姓名",prop:"name",align:"center",width:100 },
	  { title: "所属部门",prop:"department_name",align:"center",width:120 },
	  { title: "职位名称",prop:"position",align:"center",width:100 },
	  { title: "性别", prop:"gender",align:"center",width:"" },
	  { title: "人员性质", prop:"type",align:"center",width:""},
	  { title: "工龄",prop:"seniority",align:"center",width:""},
	  { title: "合同到期时间",prop:"contract",align:"center",width:100 },
	  { title: "进入支部时间",prop:"entry_time",align:"center",width:100}, 
	])
	let  user_DefalutSelect =ref(["姓名", "职位名称", "性别", "工龄", "人员性质", "合同到期时间", "所属部门"]);
	const user_columns = ref(user_DefalutList.value)
	const user_checklist=ref(user_DefalutSelect.value);
	const user_columnsTemp=ref(user_DefalutList.value);
	const user_checklistTemp=ref(user_DefalutSelect.value);
	// user End 字段表
	
	// doc START 公文管理
	let doc_DefalutList = ref([
	  { title: "id",prop:"id",align:"center",width:100 },
	  { title: "编号",prop:"doc_no",align:"center",width:120 },
	  { title: "标题",prop:"title",align:"center",width:100 },
	  { title: "添加时间", prop:"add_time_text",align:"center",width:"" },
	  { title: "审核状态", prop:"is_check",align:"center",width:""},
	  { title: "显示",prop:"status",align:"center",width:""},
	])
	let  doc_DefalutSelect =ref(["id", "编号", "标题", "添加时间", "审核状态", "显示"]);
	const doc_columns = ref(doc_DefalutList.value)
	const doc_checklist=ref(doc_DefalutSelect.value);
	const doc_columnsTemp=ref(doc_DefalutList.value);
	const doc_checklistTemp=ref(doc_DefalutSelect.value);
	// doc End 字段表
	
	
	//  docReview START 公文管理->公文审核
	let docReview_DefalutList = ref([
	  { title: "id",prop:"id",align:"center",width:55 },
	  { title: "标题", prop:"doc[0].title",align:"center",width:180 },
	  { title: "编号",prop:"doc[0].doc_no",align:"center",width:120 },
	  { title: "提交人",prop:"doc[0].user.name",align:"center",width:100 },
	  { title: "添加时间", prop:"add_time_text",align:"center",width:120},
	  { title: "审核状态",prop:"status",align:"center",width:""},
	  { title: "审核备注",prop:"mark",align:"center",width:""},
	])
	let  docReview_DefalutSelect =ref(["id", "提交人", "编号",'标题', "添加时间", "审核状态", "审核备注"]);
	const docReview_columns = ref(docReview_DefalutList.value)
	const docReview_checklist=ref(docReview_DefalutSelect.value);
	const docReview_columnsTemp=ref(docReview_DefalutList.value);
	const docReview_checklistTemp=ref(docReview_DefalutSelect.value);
	// docReview End 字段表
	
	//  docList START 公文管理->公文列表
	let docList_DefalutList = ref([
	  { title: "id",prop:"id",align:"center",width:55 },
	  { title: "标题",prop:"title",align:"center",width:180 },
	  { title: "编号", prop:"doc_no",align:"center",width:120 },
	  { title: "发布时间",prop:"add_time_text",align:"center",width:100 },
	])
	let  docList_DefalutSelect =ref(["id", "编号", "标题",'发布时间']);
	const docList_columns = ref(docList_DefalutList.value)
	const docList_checklist=ref(docList_DefalutSelect.value);
	const docList_columnsTemp=ref(docList_DefalutList.value);
	const docList_checklistTemp=ref(docList_DefalutSelect.value);
	// docList End 字段表
	
	//  engine START 工程管理->工程管理
	let engine_DefalutList = ref([
	  { title: "id",prop:"id",align:"center",width:55 },
	  { title: "工程名称",prop:"name",align:"center",width:180 },
	  { title: "所属公司", prop:"company.name",align:"center",width:180 },
	  { title: "负责人",prop:"directorInfo.name",align:"center",width:120 },
	  { title: "添加时间",prop:"add_time_text",align:"center",width:140 }	 
	])
	let  engine_DefalutSelect =ref(["id", "工程名称", "所属公司",'负责人','添加时间']);
	const engine_columns = ref(engine_DefalutList.value)
	const engine_checklist=ref(engine_DefalutSelect.value);
	const engine_columnsTemp=ref(engine_DefalutList.value);
	const engine_checklistTemp=ref(engine_DefalutSelect.value);
	// engine End 字段表
	
	//  engine START 工程管理->工程管理
	let engineSche_DefalutList = ref([
	  { title: "id",prop:"id",align:"center",width:55 },
	  { title: "工程名称",prop:"name",align:"center",width:180 },
	  { title: "所属公司", prop:"company.name",align:"center",width:180 },
	  { title: "负责人",prop:"directorInfo.name",align:"center",width:120 },
	  { title: "添加时间",prop:"add_time_text",align:"center",width:140 }	 
	])
	let  engineSche_DefalutSelect =ref(["id", "工程名称", "所属公司",'负责人','添加时间']);
	const engineSche_columns = ref(engineSche_DefalutList.value)
	const engineSche_checklist=ref(engineSche_DefalutSelect.value);
	const engineSche_columnsTemp=ref(engineSche_DefalutList.value);
	const engineSche_checklistTemp=ref(engineSche_DefalutSelect.value);
	// engine End 字段表
	
	
	//  engine START 资产管理->资产管理
	let asset_DefalutList = ref([
	  { title: "id",prop:"id",align:"center",width:55 },
	  { title: "标题",prop:"name",align:"center",width:180 },
	  { title: "所属公司", prop:"company.name",align:"center",width:180 },
	  { title: "所属类目",prop:"class_info.class_name",align:"center",width:120 }
	])
	let  asset_DefalutSelect =ref(["id", "标题", "所属公司",'所属类目']);
	const asset_columns = ref(asset_DefalutList.value)
	const asset_checklist=ref(asset_DefalutSelect.value);
	const asset_columnsTemp=ref(asset_DefalutList.value);
	const asset_checklistTemp=ref(asset_DefalutSelect.value);
	// engine End 字段表
	
	
	//  kaoqin START 考勤管理
	let kaoqin_DefalutList = ref([
	  { title: "姓名",prop:"name",align:"center",width:100 },
	  { title: "所属公司",prop:"company",align:"center",width:180 },
	  { title: "所属部门", prop:"department",align:"center",width:180 },
	  { title: "出勤",prop:"chuqin",align:"center",width:80 },
	  { title: "事假",prop:"shijia",align:"center",width:80 },
	  { title: "病假",prop:"bingjia",align:"center",width:80 },
	  { title: "年假",prop:"nianjia",align:"center",width:80 },
	  { title: "旷工",prop:"kuanggong",align:"center",width:80 },
	  { title: "迟到",prop:"chidao",align:"center",width:80 },
	  { title: "早退",prop:"zaotui",align:"center",width:80 },
	  { title: "忘打卡",prop:"wangdaka",align:"center",width:80 }
	])
	let  kaoqin_DefalutSelect =ref(["姓名",'出勤','事假','病假','年假','旷工','迟到','早退','忘打卡']);
	const kaoqin_columns = ref(kaoqin_DefalutList.value)
	const kaoqin_checklist=ref(kaoqin_DefalutSelect.value);
	const kaoqin_columnsTemp=ref(kaoqin_DefalutList.value);
	const kaoqin_checklistTemp=ref(kaoqin_DefalutSelect.value);
	// kaoqin End 字段表
	
	
	//  vmsGoods START 物品管理
		let vmsGoods_DefalutList = ref([
		  { title: "id",prop:"id",align:"center",width:80 },
		  { title: "名称",prop:"name",align:"center",width:100 },
		  { title: "图片",prop:"image",align:"center",width:70},
		  { title: "编码", prop:"sku",align:"center",width:120 },
		  { title: "物料号",prop:"part_no",align:"center",width:120 },
		  { title: "计量单位",prop:"unit",align:"center",width:100 },
		  { title: "品牌",prop:"brand",align:"center",width:120 },
		  { title: "规格型号",prop:"specs",align:"center",width:120 },
		  { title: "备注",prop:"mark",align:"center",width:200 }
		])
		let  vmsGoods_DefalutSelect =ref(["id","图片","编码","名称","计量单位","品牌","规格型号","物料号","备注"]);
		const vmsGoods_columns = ref(vmsGoods_DefalutList.value)
		const vmsGoods_checklist=ref(vmsGoods_DefalutSelect.value);
		const vmsGoods_columnsTemp=ref(vmsGoods_DefalutList.value);
		const vmsGoods_checklistTemp=ref(vmsGoods_DefalutSelect.value);
	// vmsGoods End 字段表
	

	
	//  vmsInbound START 后勤保障-》入库单
		let vmsInbound_DefalutList = ref([
		  { title: "批次号",prop:"batch_no",align:"center",width:120 },
		   { title: "操作人", prop:"user.name",align:"center",width:100 },
		  { title: "所属公司",prop:"company.name",align:"center",width:150 },
		  { title: "仓库",prop:"stockroom.name",align:"center",width:120},
		  { title: "入库时间", prop:"inbound_time",align:"center",width:100 },
		  { title: "备注",prop:"mark",align:"center",width:150 },
		  { title: "类型",prop:"type",align:"center",width:100 }
		])
		let  vmsInbound_DefalutSelect =ref(["批次号","操作人","所属公司","仓库","入库时间","备注"]);
		const vmsInbound_columns = ref(vmsInbound_DefalutList.value)
		const vmsInbound_checklist=ref(vmsInbound_DefalutSelect.value);
		const vmsInbound_columnsTemp=ref(vmsInbound_DefalutList.value);
		const vmsInbound_checklistTemp=ref(vmsInbound_DefalutSelect.value);
	// vmsInbound End 字段表
	
	//  vmsOutbound START 后勤保障-》出库单
		let vmsOutbound_DefalutList = ref([
		  { title: "批次号",prop:"batch_no",align:"center",width:120 },
		  { title: "操作人", prop:"user.name",align:"center",width:100 },
		  { title: "所属公司",prop:"company.name",align:"center",width:150 },
		  { title: "仓库",prop:"stockroom.name",align:"center",width:120},
		  { title: "出库时间", prop:"outbound_time",align:"center",width:100 },
		  { title: "备注",prop:"mark",align:"center",width:150 },
		  { title: "类型",prop:"type",align:"center",width:100 }
		])
		let  vmsOutbound_DefalutSelect =ref(["批次号","操作人","所属公司","仓库","出库时间","备注"]);
		const vmsOutbound_columns = ref(vmsOutbound_DefalutList.value)
		const vmsOutbound_checklist=ref(vmsOutbound_DefalutSelect.value);
		const vmsOutbound_columnsTemp=ref(vmsOutbound_DefalutList.value);
		const vmsOutbound_checklistTemp=ref(vmsOutbound_DefalutSelect.value);
	// vmsOutbound End 字段表
	

	//  vmsAllotbound START 后勤保障-》调拨单
		let vmsAllotbound_DefalutList = ref([
		  { title: "批次号",prop:"batch_no",align:"center",width:120 },
		   { title: "操作人",prop:"user.name",align:"center",width:100 },
		  { title: "出仓公司", prop:"outbound_company.name",align:"center",width:150 },
		  { title: "出仓库",prop:"outbound_stockroom.name",align:"center",width:120 },
		  { title: "入仓公司",prop:"inbound_company.name",align:"center",width:150},
		  { title: "入仓库", prop:"inbound_stockroom.name",align:"center",width:120 },
		  { title: "调拨时间",prop:"allot_time",align:"center",width:100 },
		   { title: "备注",prop:"mark",align:"center",width:150 },
		  { title: "类型",prop:"type",align:"center",width:100 }
		 
		])
		let  vmsAllotbound_DefalutSelect =ref(["批次号","出仓公司","出仓库","入仓公司","入仓库","操作人","调拨时间","备注"]);
		const vmsAllotbound_columns = ref(vmsAllotbound_DefalutList.value)
		const vmsAllotbound_checklist=ref(vmsAllotbound_DefalutSelect.value);
		const vmsAllotbound_columnsTemp=ref(vmsAllotbound_DefalutList.value);
		const vmsAllotbound_checklistTemp=ref(vmsAllotbound_DefalutSelect.value);
	// vmsOutbound End 字段表
	
	
	//   vmsStock START 后勤保障-》库存查看
		let vmsStock_DefalutList = ref([
		  { title: "图片",prop:"goods.image",align:"center",width:120 },
		   { title: "物品名称",prop:"goods.name",align:"center",width:100 },
		  { title: "所属公司", prop:"company.name",align:"center",width:150 },
		  { title: "仓位",prop:"stockroom.name",align:"center",width:120 },
		  { title: "库存数量",prop:"num",align:"center",width:150},
		])
		let  vmsStock_DefalutSelect =ref(["图片","物品名称","所属公司","仓位","库存数量"]);
		const vmsStock_columns = ref(vmsStock_DefalutList.value)
		const vmsStock_checklist=ref(vmsStock_DefalutSelect.value);
		const vmsStock_columnsTemp=ref(vmsStock_DefalutList.value);
		const vmsStock_checklistTemp=ref(vmsStock_DefalutSelect.value);
	//  vmsStock End 字段表
	
	//  vmsStocktaking START 后勤保障-》库存盘点
		let vmsStocktaking_DefalutList = ref([
		  { title: "所属公司",prop:"company.name",align:"center",width:150 },
		   { title: "盘点仓库",prop:"stockroom.name",align:"center",width:120 },
		  { title: "盘点时间", prop:"pd_time",align:"center",width:100 },
		  { title: "负责人",prop:"director_info.name",align:"center",width:100 },
		  { title: "状态",prop:"status",align:"center",width:100},
		  { title: "备注",prop:"mark",align:"center",width:150}
		])
		let vmsStocktaking_DefalutSelect =ref(["所属公司","盘点仓库","盘点时间","负责人","状态","备注"]);
		const vmsStocktaking_columns = ref(vmsStocktaking_DefalutList.value)
		const vmsStocktaking_checklist=ref(vmsStocktaking_DefalutSelect.value);
		const vmsStocktaking_columnsTemp=ref(vmsStocktaking_DefalutList.value);
		const vmsStocktaking_checklistTemp=ref(vmsStocktaking_DefalutSelect.value);
	// vmsOutbound End 字段表
	
	

	// 获取信息(用户昵称、头像、角色集合、权限集合)
	function initTableList() {
		return new Promise((resolve, reject) => {
			console.log('刷新数据->RefreshLocalStorage_tableList')
			user_columnsTemp.value =_.cloneDeep(user_columns.value) ;
			user_checklistTemp.value = _.cloneDeep(user_checklist.value);
			resolve(1);
		});
	}
	return {
		initTableList,
		// org 党支部 模块
		org_DefalutList,
		org_DefalutSelect,
		org_columns,
		org_checklist,
		org_columnsTemp,
		org_checklistTemp,
		
		// user 人员管理 模块
		user_DefalutList,
		user_DefalutSelect,
		user_checklistTemp,
		user_columnsTemp,
        user_columns,
		user_checklist,
		// doc 公文管理=>公文管理 模块
		doc_DefalutList,
		doc_DefalutSelect,
		doc_columns,
		doc_checklist,
		doc_columnsTemp,
		doc_checklistTemp,
		// docReview 公文管理=>公文审核 模块
		docReview_DefalutList,
		docReview_DefalutSelect,
		docReview_columns,
		docReview_checklist,
		docReview_columnsTemp,
		docReview_checklistTemp,
		
		// docList 公文管理=>公文列表 模块
		docList_DefalutList,
		docList_DefalutSelect,
		docList_columns,
		docList_checklist,
		docList_columnsTemp,
		docList_checklistTemp,
		
		// engine 工程管理=>工程管理 模块
		engine_DefalutList,
		engine_DefalutSelect,
		engine_columns,
		engine_checklist,
		engine_columnsTemp,
		engine_checklistTemp,
		
		// engineSche 工程管理=>工程进度 模块
		engineSche_DefalutList,
		engineSche_DefalutSelect,
		engineSche_columns,
		engineSche_checklist,
		engineSche_columnsTemp,
		engineSche_checklistTemp,
		
		// asset 资产管理=>资产管理 模块
		asset_DefalutList,
		asset_DefalutSelect,
		asset_columns,
		asset_checklist,
		asset_columnsTemp,
		asset_checklistTemp,
		
		// asset 考勤管理=>考勤管理 模块
		kaoqin_DefalutList,
		kaoqin_DefalutSelect,
		kaoqin_columns,
		kaoqin_checklist,
		kaoqin_columnsTemp,
		kaoqin_checklistTemp,
		
		// vmsGoods 后勤管理=>物品管理 模块
		vmsGoods_DefalutList,
		vmsGoods_DefalutSelect,
		vmsGoods_columns,
		vmsGoods_checklist,
		vmsGoods_columnsTemp,
		vmsGoods_checklistTemp,
		
		// vmsInbound 后勤管理=>入库单 模块
		vmsInbound_DefalutList,
		vmsInbound_DefalutSelect,
		vmsInbound_columns,
		vmsInbound_checklist,
		vmsInbound_columnsTemp,
		vmsInbound_checklistTemp,
		
		// vmsOnbound 后勤管理=>出库单 模块
		vmsOutbound_DefalutList,
		vmsOutbound_DefalutSelect,
		vmsOutbound_columns,
		vmsOutbound_checklist,
		vmsOutbound_columnsTemp,
		vmsOutbound_checklistTemp,
		
		// vmsAllotbound 后勤管理=>调拨单 模块
		vmsAllotbound_DefalutList,
		vmsAllotbound_DefalutSelect,
		vmsAllotbound_columns,
		vmsAllotbound_checklist,
		vmsAllotbound_columnsTemp,
		vmsAllotbound_checklistTemp,
		
		// vmsStock 后勤管理=>库存查看 模块
		vmsStock_DefalutList,
		vmsStock_DefalutSelect,
		vmsStock_columns,
		vmsStock_checklist,
		vmsStock_columnsTemp,
		vmsStock_checklistTemp,
		
		// vmsStocktaking 后勤管理=>库存盘点 模块
		vmsStocktaking_DefalutList,
		vmsStocktaking_DefalutSelect,
		vmsStocktaking_columns,
		vmsStocktaking_checklist,
		vmsStocktaking_columnsTemp,
		vmsStocktaking_checklistTemp
		
	};
},{
	// 'user_columns','user_checklist','user_dropCol'
	persist: {
		key: 'tableFile', 
		storage: localStorage, 
		paths: [],
	},
});